package com.example.demo01.Controller.webController;

import com.alibaba.fastjson.JSON;
import com.example.demo01.Service.webService.ClientUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ClientUserController {

    @Autowired
    ClientUserService clientUserService;

    /**
     * 获取所有用户信息
     * */
    @RequestMapping("/clinetuser/GET/allusers")
    public String getAllClientUsers(){
        return JSON.toJSONString(clientUserService.getAllClientUsers());
    }

    /**
     * 根据用户身份证号获取用户的详细信息
     * */
    @RequestMapping("/clinetuser/GET/userbyidnum")
    public String getDetailInfoByIdNum(
            @RequestParam(value = "idnum",required = false,defaultValue = "") String idnum){
        if (idnum.length()==0) {
            return JSON.toJSONString("{errorCode:400}");
        }
        return JSON.toJSONString(clientUserService.getDetailInfoByIdNum(idnum));
    }

}
